﻿using System.Windows.Forms;
using Firestarter.DB.Schema.UI;
using Habanero.Test;
using NUnit.Framework;
using Habanero.Faces.Base;

namespace Firestarter.DB.Schema.Test.UI
{
    [TestFixture]
    public class TestDatabaseInfoTreeViewWin : TestBase
    {

        // ReSharper disable InconsistentNaming
        [Test]
        public void Test_Construct()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DatabaseInfoTreeViewWin treeView = new DatabaseInfoTreeViewWin(GlobalUIRegistry.ControlFactory);

            //---------------Test Result -----------------------
            Assert.IsNotNull(treeView);
        }
        [Test]
        public void Test_MouseClick_WhenAttachingDelegate_ShouldFireWhenEventIsTriggered()
        {
            //---------------Set up test pack-------------------
            bool wasCalled = false;
            DatabaseInfoTreeViewWin treeView = new DatabaseInfoTreeViewWin(GlobalUIRegistry.ControlFactory);
            treeView.MouseClick += (sender, args) => wasCalled = true;

            //---------------Assert Precondition----------------
            Assert.IsFalse(wasCalled);            
            
            //---------------Execute Test ----------------------
            treeView.PerformMouseClick(GetRandomMouseEventArgs());
            //---------------Test Result -----------------------
            Assert.IsTrue(wasCalled);
        }

        private static MouseEventArgs GetRandomMouseEventArgs()
        {
            return new MouseEventArgs(TestUtil.GetRandomEnum<MouseButtons>(),TestUtil.GetRandomInt(),TestUtil.GetRandomInt(),TestUtil.GetRandomInt(),TestUtil.GetRandomInt());
        }

        // ReSharper restore InconsistentNaming
    }
}
